<?php

/**
 * job actions.
 *
 * @package    Jobeet
 * @subpackage job
 * @author     Your name here
 */
class jobActions extends sfActions
{
  public function executeIndex(sfWebRequest $request)
  {
   
    $this->jobeet_jobs = JobeetJobPeer::doSelect(new Criteria());
    $this->gMap = new GMap();
    $this->gMapClient = new gMapClient('ABQIAAAAnfs7bKE82qgb3Zc2YyS-oBT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSySz_REpPq-4WZA27OwgbtyR3VcA');
    $this->gMap->setGMapClient($this->gMapClient);
     
    $this->gMap->setCenter(6.053161,-65.665039);
    $this->gMap->setZoom(6);
    $this->gMap->addMarker(new GMapMarker(51.245475,6.821373));

    $this->gMap->addMarker(new GMapMarker(46.262248,6.115969));
 sfConfig::get('sf_ logging_enabled');
    
//$this->logMessage('help me!', 'info');

 
 $client = new SOAPClient('http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl', array('features' => SOAP_SINGLE_ELEMENT_ARRAYS));
try
{
    $params = array('ZIP' => '94568');
	
	//$weather = $client->GetCityWeatherByZIP($params);
       $weather =  $client->__soapCall('GetCityWeatherByZIP', array('parameters' => $params));

       
        //$xmlDatosUsuario = $xmlData->NewDataSet->DATOS_USUARIO;


        //$xmlData = simplexml_load_string($weather);
	//$xmlDatosWeather= $weather->GetCityWeatherByZIPResult->Result;
       var_dump($weather);
       //var_dump($weather->GetCityWeatherByZIPResult->Description);
       $this->weather_description = $weather->GetCityWeatherByZIPResult->Description;
        //$this->weather = $weather;
} catch (SOAPFault $exception) {
	// if we hit an error, print the exception and the XML we sent
	print $exception;
	print htmlspecialchars($client->__getLastRequest());
	exit;
}


  }
 
  public function executeShow(sfWebRequest $request)
  {
    //$this->jobeet_jobs = JobeetJobPeer::retrieveByPk($request->getParameter('id'));
    //$this->forward404Unless($this->jobeet_jobs);


    $this->job = JobeetJobPeer::retrieveByPk($request->getParameter('id'));
  $this->forward404Unless($this->job);
  }

  // apps/frontend/modules/job/actions/actions.class.php
public function executeSearch(sfWebRequest $request)
{
  $this->forwardUnless($query = $request->getParameter('query'), 'job', 'index');

  $this->jobs = JobeetJobPeer::getForLuceneQuery($query);

  if ($request->isXmlHttpRequest())
  {
    if ('*' == $query || !$this->jobs)
    {
      return $this->renderText('No results.');
    }

    //return $this->renderPartial('job/list', array('jobs' => $this->jobs));
  }
}
  public function executeNew(sfWebRequest $request)
  {
    $this->form = new JobeetJobForm();
  }

  public function executeCreate(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST));

    $this->form = new JobeetJobForm();

    $this->processForm($request, $this->form);

    $this->setTemplate('new');
  }

  public function executeFooBar(sfWebRequest $request)
{
  $this->foo = 'bar';
  $this->bar = array('bar', 'baz');
}

  public function executeEdit(sfWebRequest $request)
  {
    $this->forward404Unless($JobeetJob = JobeetJobPeer::retrieveByPk($request->getParameter('id')), sprintf('Object JobeetJob does not exist (%s).', $request->getParameter('id')));
    $this->form = new JobeetJobForm($JobeetJob);
  }

  public function executeUpdate(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
    $this->forward404Unless($JobeetJob = JobeetJobPeer::retrieveByPk($request->getParameter('id')), sprintf('Object JobeetJob does not exist (%s).', $request->getParameter('id')));
    $this->form = new JobeetJobForm($JobeetJob);

    $this->processForm($request, $this->form);

    $this->setTemplate('edit');
  }

  public function executeDelete(sfWebRequest $request)
  {
    $request->checkCSRFProtection();

    $this->forward404Unless($JobeetJob = JobeetJobPeer::retrieveByPk($request->getParameter('id')), sprintf('Object JobeetJob does not exist (%s).', $request->getParameter('id')));
    $JobeetJob->delete();

    $this->redirect('job/index');
  }

  protected function processForm(sfWebRequest $request, sfForm $form)
  {
    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
    if ($form->isValid())
    {
      $JobeetJob = $form->save();

      $this->redirect('job/edit?id='.$JobeetJob->getId());
    }
  }
}
